home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Freeware / Programare / highlight / highlight-W32GUI-2.2-10b-Setup.exe / {app} / src / linewrapper.h < prev    next >
C/C++ Source or Header  |  2004-10-20  |  2KB  |  82 lines

  1. /***************************************************************************
  2.                         linewrapper.cpp  -  description
  3.                              -------------------
  4.     begin                : Sa Jan 00 2004
  5.     copyright            : (C) 2004 by Andre Simon
  6.     email                : andre.simon1@gmx.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This program is free software; you can redistribute it and/or modify  *
  12.  *   it under the terms of the GNU General Public License as published by  *
  13.  *   the Free Software Foundation; either version 2 of the License, or     *
  14.  *   (at your option) any later version.                                   *
  15.  *                                                                         *
  16.  ***************************************************************************/
  17.  
  18. #ifndef LINEWRAPPER_H
  19. #define LINEWRAPPER_H
  20.  
  21. #define LB_CHARS " \t[](){}-+<>.:,;"
  22. #define WS_CHARS " \n\r\t"
  23.  
  24. #include <string>
  25. #include <iostream>
  26.  
  27. #include "stringtools.h"
  28.  
  29. namespace highlight {
  30.  
  31. /** \brief Class which provides intelligent line wrapping.
  32. * @author Andre Simon
  33. */
  34.  
  35. class LineWrapper{
  36. public:
  37.     /** Constructor
  38.      \param maxlength Max length of line
  39.      \param indentAfterOpenBraces Test if statements and function parameters should be indented
  40.     */
  41.     LineWrapper(unsigned int maxlength=80, bool indentAfterOpenBraces=true);
  42.  
  43.     LineWrapper();
  44.  
  45.     ~LineWrapper();
  46.  
  47.     /**
  48.      \return True if current line can be wrapped again
  49.     */
  50.     bool hasMoreLines();
  51.  
  52.     /**
  53.      Sets new line to be wrapped
  54.      \param newline New line
  55.     */
  56.     void setLine(const std::string  newline);
  57.  
  58.     /**
  59.      The method will indent function calls and statements
  60.      \return Next line
  61.     */
  62.     std::string  getNextLine();
  63.  
  64.     /**
  65.      \return True if lines following open braces should be indented
  66.     */
  67.     bool indentCode();
  68.  
  69. private:
  70.     const unsigned int MAX_LINE_LENGTH;
  71.  
  72.     std::string line, wsPrefix;
  73.     unsigned int index;
  74.     size_t wsPrefixLength;
  75.     bool hasMore, indentAfterOpenBraces;
  76.     bool redefineWsPrefix;
  77. };
  78.  
  79. }
  80.  
  81. #endif
  82.